package com.service.atf.reply.service;

import com.service.atf.base.exception.TFException;
import com.service.atf.base.model.Account;
import com.service.atf.base.model.TFGameEnter;
import com.service.atf.base.utils.ATFConstants;
import com.service.atf.base.utils.ATFLogger;
import com.service.atf.reply.ac.AccountManager;
import com.service.atf.reply.core.IReadExecutor;
import com.luotao.devp.base.utils.StringUtils;

import java.util.Map;

/**
 * User: luotao
 * Date: 12-3-21
 * Time: 17:00:00
 */
public class GameEnterService8 implements IReadExecutor<TFGameEnter> {
    private static final String KEY_LAST_FLOW = "lastFlow";

    @Override
    public boolean isNotify() {
        return true;
    }

    public void initOut(Map out) {
        out.put(KEY_LAST_FLOW, 0);
    }

    @Override
    public void execute(boolean recover, AccountManager accountManager, TFGameEnter gameEnter, Map out) {
        // Validata.validataCustomerCode(this, gameEnter.getCustomerCode());
        Account account = accountManager.getBussAccount(gameEnter.getCustomerCode());

        //  Validata.validataACNull(this, gameEnter.getCustomerCode(), account);

        if (account == null || StringUtils.isEmpty(account.getCustomerCode())) {
            String msg = "���û�δ��¼" + gameEnter.getCustomerCode();
            ATFLogger.syserr(msg);
            throw new TFException(ATFConstants.ATF_AC_NULL, msg);
        }
        account.setStartTime(gameEnter.getEnterGameDate());
        AccountManager.getInstance().updateAccount(account);
        out.put(KEY_LAST_FLOW, account.getLastFlowId());
    }
}
